/* =============================================================================
# FileName    :	datamover_model.sv
# Author      :	author
# Email       :	email@email.com
# Description :	datamover s2mm仿真模型, 
# Version     :	1.0
# LastChange  :	2025-05-02 20:20:16
# ChangeLog   :	
============================================================================= */

`timescale  1 ns/1 ps

`include "/home/wj/study/hdl_example/datamover/intf.sv"
module datamover_model #
(
    parameter               WIDTH = 32
)
(
    input                       clk,
    if_axi_datamover.master     datamover_slave
);

assign                  datamover_slave.sts_tkeep = 1'b1;

assign                  datamover_slave.tready = 1'b1;

logic   [31:00]             data_cnt = 0;
always_ff @ (posedge clk)
begin
    if(data_cnt >= datamover_slave.cmd_tdata[22:00] - WIDTH / 8)
        data_cnt <= 0;
    else
    begin
        if(datamover_slave.tvalid & datamover_slave.tready)
            data_cnt <= data_cnt + WIDTH/8;
    end
end


initial
begin
    datamover_slave.cmd_tready = 1'b0;
    repeat(1000)
    begin
        wait(datamover_slave.cmd_tvalid);
        datamover_slave.cmd_tready = 1'b1;
        @(posedge clk);
        datamover_slave.cmd_tready = 1'b0;
    end
end

initial
begin
    datamover_slave.sts_tvalid = 0;
    datamover_slave.sts_tdata = 0;
    datamover_slave.sts_tlast = 0;

    repeat(1000)
    begin
        wait(datamover_slave.tlast);
        #100ns; @(posedge clk);
        datamover_slave.sts_tvalid = 1;
        @(posedge clk);
        datamover_slave.sts_tvalid = 0;

    end
end

endmodule
